{% extends "base.html" %}

{% block title %}注册 - 墨韵图书共享平台{% endblock %}

{% block content %}
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card ink-card">
                <div class="card-header">
                    <h5 class="mb-0">用户注册</h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        <div class="mb-3">
                            <label for="student_id" class="form-label">学号</label>
                            <input type="text" class="form-control" id="student_id" name="student_id" required>
                        </div>
                        
                        <div class="mb-3">
                            <label for="username" class="form-label">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" required>
                        </div>
                        
                        <div class="mb-3">
                            <label for="email" class="form-label">邮箱 (选填)</label>
                            <input type="email" class="form-control" id="email" name="email">
                        </div>
                        
                        <div class="mb-3">
                            <label for="password" class="form-label">密码</label>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>
                        
                        <div class="mb-3 form-check">
                            <input type="checkbox" class="form-check-input" id="is_teacher" name="is_teacher">
                            <label class="form-check-label" for="is_teacher">我是教师</label>
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-user-plus me-2"></i> 注册
                            </button>
                        </div>
                    </form>
                    
                    <div class="text-center mt-3">
                        <p>已有账号？ <a href="{{ url_for('login') }}">立即登录</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block scripts %}
<script>
document.addEventListener('DOMContentLoaded', function() {
    const form = document.querySelector('form');
    form.addEventListener('submit', function(e) {
        const password = document.getElementById('password').value;
        const confirmPassword = document.getElementById('confirm_password').value;
        
        if (password !== confirmPassword) {
            e.preventDefault();
            alert('两次输入的密码不一致！');
        }
    });
});
</script>
{% endblock %} 